package model

import (
	"manager/model/entity"
)

// UserSettingCreateRequest 创建现场数据
type UserSettingCreateRequest struct {
	UserId int64 `json:"user_id"`

	Face int `json:"face"`

	Fingerprint int `json:"fingerprint"`

	Vibration int `json:"vibration"`

	CutPower int `json:"cut_power"`

	ChargeMonitor int `json:"charge_monitor"`

	GuardAlarm int `json:"guard_alarm"`

	FaultAlarm int `json:"fault_alarm"`

	UpdatedAt int64 `json:"updated_at"`
}

// UserSettingUpdateRequest 更新现场数据
type UserSettingUpdateRequest struct {
	Id int64 `json:"id"`

	UserId *int64 `json:"user_id"`

	Face *int `json:"face"`

	Fingerprint *int `json:"fingerprint"`

	Vibration *int `json:"vibration"`

	CutPower *int `json:"cut_power"`

	ChargeMonitor *int `json:"charge_monitor"`

	GuardAlarm *int `json:"guard_alarm"`

	FaultAlarm *int `json:"fault_alarm"`

	CreatedAt int64 `json:"created_at"`

	UpdatedAt *int64 `json:"updated_at"`
}

// UserSettingListRequest 列表现场数据
type UserSettingListRequest struct {
	Index int `json:"index"`
	Size  int `json:"size"`

	Id int64 `json:"id"`

	UserId *int64 `json:"user_id"`

	Face *int `json:"face"`

	Fingerprint *int `json:"fingerprint"`

	Vibration *int `json:"vibration"`

	CutPower *int `json:"cut_power"`

	ChargeMonitor *int `json:"charge_monitor"`

	GuardAlarm *int `json:"guard_alarm"`

	FaultAlarm *int `json:"fault_alarm"`

	UpdatedAt *int64 `json:"updated_at"`
}

// UserSettingListResponse 列表回包数据
type UserSettingListResponse struct {
	Total int                `json:"total"`
	List  []*UserSettingInfo `json:"list"`
}

// UserSettingInfoRequest 列表现场数据
type UserSettingInfoRequest struct {
	Id int64 `json:"id"`

	UserId *int64 `json:"user_id"`

	Face *int `json:"face"`

	Fingerprint *int `json:"fingerprint"`

	Vibration *int `json:"vibration"`

	CutPower *int `json:"cut_power"`

	ChargeMonitor *int `json:"charge_monitor"`

	GuardAlarm *int `json:"guard_alarm"`

	FaultAlarm *int `json:"fault_alarm"`

	UpdatedAt *int64 `json:"updated_at"`
}

// UserSettingInfo 详细数据
type UserSettingInfo struct {
	Id int64 `json:"id"`

	UserId int64 `json:"user_id"`

	Face int `json:"face"`

	Fingerprint int `json:"fingerprint"`

	Vibration int `json:"vibration"`

	CutPower int `json:"cut_power"`

	ChargeMonitor int `json:"charge_monitor"`

	GuardAlarm int `json:"guard_alarm"`

	FaultAlarm int `json:"fault_alarm"`

	CreatedAt int64 `json:"created_at"`

	UpdatedAt int64 `json:"updated_at"`
}

// UserSettingDeleteRequest 删除现场数据
type UserSettingDeleteRequest struct {
	Id int64 `json:"id"`
}

// UserSettingsEntityToDto entity数据转换
func UserSettingsEntityToDto(userSettings []*entity.UserSetting) []*UserSettingInfo {
	out := make([]*UserSettingInfo, 0, len(userSettings))
	for _, c := range userSettings {
		out = append(out, UserSettingEntityToDto(c))
	}
	return out
}

// UserSettingEntityToDto entity数据转换
func UserSettingEntityToDto(e *entity.UserSetting) *UserSettingInfo {
	return &UserSettingInfo{

		Id: e.Id,

		UserId: e.UserId,

		Face: e.Face,

		Fingerprint: e.Fingerprint,

		Vibration: e.Vibration,

		CutPower: e.CutPower,

		ChargeMonitor: e.ChargeMonitor,

		GuardAlarm: e.GuardAlarm,

		FaultAlarm: e.FaultAlarm,

		CreatedAt: e.CreatedAt,

		UpdatedAt: e.UpdatedAt,
	}
}
